<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of tfile</title>
  <meta name="keywords" content="tfile">
  <meta name="description" content="tfile reads the data from an RDI ASCII output file and puts the">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
  <script type="text/javascript">
    if (top.frames.length == 0) { top.location = "../../index.html"; };
  </script>
</head>
<body>
<a name="_top"></a>
<!-- ../menu.html trunk --><!-- menu.html utils -->
<h1>tfile
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>tfile reads the data from an RDI ASCII output file and puts the</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [A]=tfile(fullName,screenData,ignoreBS); </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> tfile reads the data from an RDI ASCII output file and puts the
 data in a Matlab data structure with major groups of:
 Sup - supporing data
 Wat - water data
 Nav - navigation data including GPS.
 Sensor - Sensor data
 Q - discharge related data

 The data can be screened (screenData=1) so that invalid data are set to
 nan or data reflect strictly the ASCII output file (screenData=0). If
 screenData=0 then the data reflect the ASCII file and -32768 and other
 RDI defined values are left in the data structure. If screenData=1 the
 RDI defined values are trapped and set to nan for many variables.

 WinRiver II will sometimes put a $ instead of the correct values for
 intensity of backscatter. Setting ignoreBS=1 will skip decoding the
 intensity of backscatter data to compensate for this bug in WR2.

 David S. Mueller, USGS, Office of Surface Water
 Frank L. Engel, USGS, Illinois Water Science Center</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="nansum.html" class="code" title="function y = nansum(x,dim)">nansum</a>	NANSUM Sum, ignoring NaNs.</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="ReadFiles.html" class="code" title="">ReadFiles</a>	% Read in multiple ASCII .TXT Files</li><li><a href="STA_MeanProfile.html" class="code" title="function sta = STA_MeanProfile(fitProf,units)">STA_MeanProfile</a>	Compute the mean priole from stationary measurements at a point.</li><li><a href="STA_MeanProfileV2.html" class="code" title="function sta = STA_MeanProfileV2(fitProf,units,StrDir)">STA_MeanProfileV2</a>	Compute the mean profile from stationary measurements at a point.</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [A]=tfile(fullName,screenData,ignoreBS);</a>
0002 <span class="comment">% tfile reads the data from an RDI ASCII output file and puts the</span>
0003 <span class="comment">% data in a Matlab data structure with major groups of:</span>
0004 <span class="comment">% Sup - supporing data</span>
0005 <span class="comment">% Wat - water data</span>
0006 <span class="comment">% Nav - navigation data including GPS.</span>
0007 <span class="comment">% Sensor - Sensor data</span>
0008 <span class="comment">% Q - discharge related data</span>
0009 <span class="comment">%</span>
0010 <span class="comment">% The data can be screened (screenData=1) so that invalid data are set to</span>
0011 <span class="comment">% nan or data reflect strictly the ASCII output file (screenData=0). If</span>
0012 <span class="comment">% screenData=0 then the data reflect the ASCII file and -32768 and other</span>
0013 <span class="comment">% RDI defined values are left in the data structure. If screenData=1 the</span>
0014 <span class="comment">% RDI defined values are trapped and set to nan for many variables.</span>
0015 <span class="comment">%</span>
0016 <span class="comment">% WinRiver II will sometimes put a $ instead of the correct values for</span>
0017 <span class="comment">% intensity of backscatter. Setting ignoreBS=1 will skip decoding the</span>
0018 <span class="comment">% intensity of backscatter data to compensate for this bug in WR2.</span>
0019 <span class="comment">%</span>
0020 <span class="comment">% David S. Mueller, USGS, Office of Surface Water</span>
0021 <span class="comment">% Frank L. Engel, USGS, Illinois Water Science Center</span>
0022 
0023 <span class="comment">%% Initial Scan of File</span>
0024 <span class="comment">%  Initial scan required to preallocate arrays. All ensembles must be</span>
0025 <span class="comment">%  scanned because RiverRay has variable number of bins.</span>
0026 
0027 <span class="comment">% Turn off LaTex interpreter to avoid subscripts in filenames containing _</span>
0028 set(0, <span class="string">'DefaulttextInterpreter'</span>, <span class="string">'none'</span>);
0029 fid=fopen(fullName);
0030 <span class="comment">% clc</span>
0031 <span class="comment">% disp(['Scanning Data File: ' fullName]);</span>
0032 idx=find(fullName==<span class="string">'\'</span>,1,<span class="string">'last'</span>);
0033 fileName=fullName(idx:end);
0034 
0035 <span class="comment">% Display waitbar</span>
0036 waitmessage=[<span class="string">'Reading '</span> fileName];
0037 hwait=waitbar(0,waitmessage);
0038 
0039 <span class="comment">% Scan Fixed Leader.</span>
0040 lineIn=fgetl(fid);
0041 lineIn=fgetl(fid);
0042 lineIn=fgetl(fid);
0043 
0044 <span class="comment">% Count lines in file.</span>
0045 k=1;
0046 fileEnd=0;
0047 
0048 <span class="comment">% Loop required to determine number of variable leader lines due to bug</span>
0049 <span class="comment">% in ASCII output from WinRiver II for reference set to NONE.</span>
0050 check=0;
0051 linecount=0;
0052 <span class="keyword">while</span> check==0
0053     lineIn=fgetl(fid);
0054     idxBT=strfind(lineIn,<span class="string">'BT'</span>);
0055     idxGGA=strfind(lineIn,<span class="string">'GGA'</span>);
0056     idxVTG=strfind(lineIn,<span class="string">'VTG'</span>);
0057     idxNone=strfind(lineIn,<span class="string">'NONE'</span>);
0058     check=<a href="nansum.html" class="code" title="function y = nansum(x,dim)">nansum</a>([idxBT idxGGA idxVTG idxNone]);
0059     linecount=linecount+1;
0060 <span class="keyword">end</span>
0061 
0062 <span class="comment">% Read number of bins in 1st ensemble</span>
0063 [bins(k),~,~,~,~,~]=strread(lineIn,<span class="string">'%f %s %s %s %f %f'</span>,1);
0064 
0065 <span class="comment">% Skip bin data</span>
0066 dummy=textscan(fid, <span class="string">'%s %*[^\n]'</span>,bins(k));
0067 
0068 <span class="comment">% Set number of leader lines to get to number of bins in variable</span>
0069 <span class="comment">% leader</span>
0070 leaderlines=linecount-1;
0071 
0072 <span class="comment">% Begin loop to determin number of ensembles and maximum number of bins</span>
0073 <span class="comment">% for preallocating arrays. Looping through the entire file is required</span>
0074 <span class="comment">% because RiverRay data have variable numbers of bins in each ensemble.</span>
0075 <span class="keyword">while</span> fileEnd==0
0076     dummy=textscan(fid, <span class="string">'%s %*[^\n]'</span>,leaderlines);
0077     <span class="keyword">if</span> length(dummy{1})&gt;1
0078         k=k+1;
0079         bins(k)=cell2mat(textscan(fid, <span class="string">'%f %*[^\n]'</span>,1));
0080         dummy=textscan(fid, <span class="string">'%s %*[^\n]'</span>,bins(k));
0081     <span class="keyword">end</span>
0082     fileEnd=feof(fid);
0083 <span class="keyword">end</span>
0084 
0085 <span class="comment">% Update waitbar</span>
0086 waitbar(0.1);
0087 <span class="comment">%% Complete scan of input file.</span>
0088 <span class="comment">% Close input file and report that the initial scan is completed.</span>
0089 fclose(fid);
0090 <span class="comment">% disp('Scan Complete');</span>
0091 
0092 <span class="comment">%% Initialize Data Structure</span>
0093 <span class="comment">% Preallocates arrays based on information from initial scan.</span>
0094 
0095 <span class="comment">% This is the number of ensembles actually contained in the input file.</span>
0096 noe=k;
0097 bins=max(bins);
0098 
0099 <span class="comment">% Initialize Data Structure.</span>
0100 Sup=struct( <span class="string">'absorption_dbpm'</span>,nan(noe,1),<span class="keyword">...</span>
0101     <span class="string">'bins'</span>,nan(noe,1),<span class="keyword">...</span>
0102     <span class="string">'binSize_cm'</span>,nan(1),<span class="keyword">...</span>
0103     <span class="string">'nBins'</span>,nan(1),<span class="keyword">...</span>
0104     <span class="string">'blank_cm'</span>,nan(1),<span class="keyword">...</span>
0105     <span class="string">'draft_cm'</span>,nan(1),<span class="keyword">...</span>
0106     <span class="string">'ensNo'</span>,nan(noe,1),<span class="keyword">...</span>
0107     <span class="string">'nPings'</span>,nan(1),<span class="keyword">...</span>
0108     <span class="string">'noEnsInSeg'</span>,nan(noe,1),<span class="keyword">...</span>
0109     <span class="string">'noe'</span>,nan(1),<span class="keyword">...</span>
0110     <span class="string">'note1'</span>,blanks(80),<span class="keyword">...</span>
0111     <span class="string">'note2'</span>,blanks(80),<span class="keyword">...</span>
0112     <span class="string">'intScaleFact_dbpcnt'</span>,nan(noe,1),<span class="keyword">...</span>
0113     <span class="string">'intUnits'</span>,repmat(blanks(5),noe,1),<span class="keyword">...</span>
0114     <span class="string">'vRef'</span>,repmat(blanks(4),noe,1),<span class="keyword">...</span>
0115     <span class="string">'wm'</span>,nan(1),<span class="keyword">...</span>
0116     <span class="string">'units'</span>,repmat(blanks(2),noe,1),<span class="keyword">...</span>
0117     <span class="string">'year'</span>,nan(noe,1),<span class="keyword">...</span>
0118     <span class="string">'month'</span>,nan(noe,1),<span class="keyword">...</span>
0119     <span class="string">'day'</span>,nan(noe,1),<span class="keyword">...</span>
0120     <span class="string">'hour'</span>,nan(noe,1),<span class="keyword">...</span>
0121     <span class="string">'minute'</span>,nan(noe,1),<span class="keyword">...</span>
0122     <span class="string">'second'</span>,nan(noe,1),<span class="keyword">...</span>
0123     <span class="string">'sec100'</span>,nan(noe,1),<span class="keyword">...</span>
0124     <span class="string">'timeElapsed_sec'</span>,nan(noe,1),<span class="keyword">...</span>
0125     <span class="string">'timeDelta_sec100'</span>,nan(1));
0126 
0127 Wat=struct( <span class="string">'binDepth'</span>,nan(bins,noe),<span class="keyword">...</span>
0128     <span class="string">'backscatter'</span>,nan(bins,noe,4),<span class="keyword">...</span>
0129     <span class="string">'vDir'</span>,nan(bins,noe),<span class="keyword">...</span>
0130     <span class="string">'vMag'</span>,nan(bins,noe),<span class="keyword">...</span>
0131     <span class="string">'vEast'</span>,nan(bins,noe),<span class="keyword">...</span>
0132     <span class="string">'vError'</span>,nan(bins,noe),<span class="keyword">...</span>
0133     <span class="string">'vNorth'</span>,nan(bins,noe),<span class="keyword">...</span>
0134     <span class="string">'vVert'</span>,nan(bins,noe),<span class="keyword">...</span>
0135     <span class="string">'percentGood'</span>,nan(bins,noe));
0136 
0137 Nav=struct( <span class="string">'bvEast'</span>,nan(noe,1),<span class="keyword">...</span>
0138     <span class="string">'bvError'</span>,nan(noe,1),<span class="keyword">...</span>
0139     <span class="string">'bvNorth'</span>,nan(noe,1),<span class="keyword">...</span>
0140     <span class="string">'bvVert'</span>,nan(noe,1),<span class="keyword">...</span>
0141     <span class="string">'depth'</span>,nan(noe,4),<span class="keyword">...</span>
0142     <span class="string">'dsDepth'</span>,nan(noe,1),<span class="keyword">...</span>
0143     <span class="string">'dmg'</span>,nan(noe,1),<span class="keyword">...</span>
0144     <span class="string">'length'</span>,nan(noe,1),<span class="keyword">...</span>
0145     <span class="string">'totDistEast'</span>,nan(noe,1),<span class="keyword">...</span>
0146     <span class="string">'totDistNorth'</span>,nan(noe,1),<span class="keyword">...</span>
0147     <span class="string">'altitude'</span>,nan(noe,1),<span class="keyword">...</span>
0148     <span class="string">'altitudeChng'</span>,nan(noe,1),<span class="keyword">...</span>
0149     <span class="string">'gpsTotDist'</span>,nan(noe,1),<span class="keyword">...</span>
0150     <span class="string">'gpsVariable'</span>,nan(noe,1),<span class="keyword">...</span>
0151     <span class="string">'gpsVeast'</span>,nan(noe,1),<span class="keyword">...</span>
0152     <span class="string">'gpsVnorth'</span>,nan(noe,1),<span class="keyword">...</span>
0153     <span class="string">'lat_deg'</span>,nan(noe,1),<span class="keyword">...</span>
0154     <span class="string">'long_deg'</span>,nan(noe,1),<span class="keyword">...</span>
0155     <span class="string">'nSats'</span>,nan(noe,1),<span class="keyword">...</span>
0156     <span class="string">'hdop'</span>,nan(noe,1));
0157 
0158 Sensor=struct(  <span class="string">'pitch_deg'</span>,nan(noe,1),<span class="keyword">...</span>
0159     <span class="string">'roll_deg'</span>,nan(noe,1),<span class="keyword">...</span>
0160     <span class="string">'heading_deg'</span>,nan(noe,1),<span class="keyword">...</span>
0161     <span class="string">'temp_degC'</span>,nan(noe,1));
0162 
0163 Q=struct(   <span class="string">'endDepth'</span>,nan(noe,1),<span class="keyword">...</span>
0164     <span class="string">'endDist'</span>,nan(noe,1),<span class="keyword">...</span>
0165     <span class="string">'bot'</span>,nan(noe,1),<span class="keyword">...</span>
0166     <span class="string">'end'</span>,nan(noe,1),<span class="keyword">...</span>
0167     <span class="string">'meas'</span>,nan(noe,1),<span class="keyword">...</span>
0168     <span class="string">'start'</span>,nan(noe,1),<span class="keyword">...</span>
0169     <span class="string">'top'</span>,nan(noe,1),<span class="keyword">...</span>
0170     <span class="string">'unit'</span>,nan(bins,noe),<span class="keyword">...</span>
0171     <span class="string">'startDepth'</span>,nan(noe,1),<span class="keyword">...</span>
0172     <span class="string">'startDist'</span>,nan(noe,1));
0173 
0174 Sup.noe=noe;
0175 
0176 <span class="comment">%% Read File and Store Data</span>
0177 <span class="comment">% All data are read and stored in preallocated data structures</span>
0178 
0179 <span class="comment">% Reopen File for Reading</span>
0180 fid=fopen(fullName);
0181 <span class="comment">% disp('Reading Data File');</span>
0182 
0183 <span class="comment">% Read Fixed Leader</span>
0184 Sup.note1=fgetl(fid);
0185 Sup.note2=fgetl(fid);
0186 C = textscan(fid,<span class="string">'%u %u %u %u %u %u %u'</span>,1);
0187 [<span class="keyword">...</span>
0188     Sup.binSize_cm,<span class="keyword">...</span>
0189     Sup.blank_cm,<span class="keyword">...</span>
0190     Sup.draft_cm,<span class="keyword">...</span>
0191     Sup.nBins,<span class="keyword">...</span>
0192     Sup.nPings,<span class="keyword">...</span>
0193     Sup.timeDelta_sec100,<span class="keyword">...</span>
0194     Sup.wm] = deal(C{:});
0195 
0196 <span class="comment">% Read Variable Leader</span>
0197 waitstep = floor(noe/100);
0198 <span class="keyword">for</span> n = 1:noe;
0199     <span class="comment">% Update the waitbar only on whole percents</span>
0200     <span class="keyword">if</span> ~mod(n, waitstep) || n==noe
0201         waitbar(0.1+n/noe);
0202     <span class="keyword">end</span>
0203     C = textscan(fid,<span class="string">'%u %u %u %u %u %f %f %u %u %f %f %f %f'</span>,1);
0204     [<span class="keyword">...</span>
0205         Sup.year(n),<span class="keyword">...</span>
0206         Sup.month(n),<span class="keyword">...</span>
0207         Sup.day(n),<span class="keyword">...</span>
0208         Sup.hour(n),<span class="keyword">...</span>
0209         Sup.minute(n),<span class="keyword">...</span>
0210         Sup.second(n),<span class="keyword">...</span>
0211         Sup.sec100(n),<span class="keyword">...</span>
0212         Sup.ensNo(n),<span class="keyword">...</span>
0213         Sup.noEnsInSeg(n),<span class="keyword">...</span>
0214         Sensor.pitch_deg(n),<span class="keyword">...</span>
0215         Sensor.roll_deg(n),<span class="keyword">...</span>
0216         Sensor.heading_deg(n),<span class="keyword">...</span>
0217         Sensor.temp_degC(n)] = deal(C{:});
0218     
0219     <span class="comment">% Required logic to account for bug in ASCII output when the</span>
0220     <span class="comment">% reference is set to NONE.</span>
0221     C = textscan(fid,<span class="string">'%f %f %f %f %f %f %f %f %f %f %f %f'</span>,1);
0222     <span class="keyword">if</span> sum(isnan([C{:}]))==0
0223         [<span class="keyword">...</span>
0224             Nav.bvEast(n),<span class="keyword">...</span>
0225             Nav.bvNorth(n),<span class="keyword">...</span>
0226             Nav.bvVert(n),<span class="keyword">...</span>
0227             Nav.bvError(n),<span class="keyword">...</span>
0228             Nav.dsDepth(n),<span class="keyword">...</span>
0229             Nav.altitude(n),<span class="keyword">...</span>
0230             Nav.altitudeChng(n),<span class="keyword">...</span>
0231             Nav.gpsVariable(n),<span class="keyword">...</span>
0232             Nav.depth(n,1),<span class="keyword">...</span>
0233             Nav.depth(n,2),<span class="keyword">...</span>
0234             Nav.depth(n,3),<span class="keyword">...</span>
0235             Nav.depth(n,4)] = deal(C{:});
0236         
0237         C = textscan(fid,<span class="string">'%f %f %f %f %f'</span>,1);
0238         [<span class="keyword">...</span>
0239             Nav.length(n),<span class="keyword">...</span>
0240             Sup.timeElapsed_sec(n),<span class="keyword">...</span>
0241             Nav.totDistNorth(n),<span class="keyword">...</span>
0242             Nav.totDistEast(n),<span class="keyword">...</span>
0243             Nav.dmg(n)] = deal(C{:});
0244         
0245         C = textscan(fid,<span class="string">'%f %f %f %f %f'</span>,1);
0246         [<span class="keyword">...</span>
0247             Nav.lat_deg(n),<span class="keyword">...</span>
0248             Nav.long_deg(n),<span class="keyword">...</span>
0249             Nav.gpsVeast(n),<span class="keyword">...</span>
0250             Nav.gpsVnorth(n),<span class="keyword">...</span>
0251             Nav.gpsTotDist(n)] = deal(C{:});
0252     <span class="keyword">else</span>
0253         [<span class="keyword">...</span>
0254             Nav.dsDepth(n),<span class="keyword">...</span>
0255             Nav.altitude(n),<span class="keyword">...</span>
0256             Nav.altitudeChng(n),<span class="keyword">...</span>
0257             Nav.gpsVariable(n),<span class="keyword">...</span>
0258             Nav.depth(n,1),<span class="keyword">...</span>
0259             Nav.depth(n,2),<span class="keyword">...</span>
0260             Nav.depth(n,3),<span class="keyword">...</span>
0261             Nav.depth(n,4)]=deal(C{1:8});
0262         
0263         C = textscan(fid,<span class="string">'%f %f %f %f %f %f'</span>,1);
0264         [<span class="keyword">...</span>
0265             dummy,<span class="keyword">...</span>
0266             Nav.lat_deg(n),<span class="keyword">...</span>
0267             Nav.long_deg(n),<span class="keyword">...</span>
0268             Nav.gpsVeast(n),<span class="keyword">...</span>
0269             Nav.gpsVnorth(n),<span class="keyword">...</span>
0270             Nav.gpsTotDist(n)] = deal(C{:});
0271     <span class="keyword">end</span>
0272     
0273     <span class="comment">% Extract HDOP and number of satellites from gpsVariable</span>
0274     <span class="keyword">if</span> Nav.gpsVariable(n)&gt;0
0275         Nav.hdop(n)=floor(Nav.gpsVariable(n))./10;  <span class="comment">%/10 added 3-12-10 by PRJ (according to TRDI WRII manual)</span>
0276         Nav.nSats(n)=(Nav.gpsVariable(n)-Nav.hdop(n).*10).*100;
0277     <span class="keyword">end</span>;
0278     
0279     C = textscan(fid,<span class="string">'%f %f %f %f %f %f %f %f %f'</span>,1);
0280     [<span class="keyword">...</span>
0281         Q.meas(n),<span class="keyword">...</span>
0282         Q.top(n),<span class="keyword">...</span>
0283         Q.bot(n),<span class="keyword">...</span>
0284         Q.start(n),<span class="keyword">...</span>
0285         Q.startDist(n),<span class="keyword">...</span>
0286         Q.end(n),<span class="keyword">...</span>
0287         Q.endDist(n),<span class="keyword">...</span>
0288         Q.startDepth(n),<span class="keyword">...</span>
0289         Q.endDepth(n)] = deal(C{:});
0290     
0291     C = textscan(fid,<span class="string">'%f %s %s %s %f %f'</span>,1);
0292     [<span class="keyword">...</span>
0293         Sup.bins(n),<span class="keyword">...</span>
0294         Sup.units,<span class="keyword">...</span>
0295         Sup.vRef,<span class="keyword">...</span>
0296         Sup.intUnits,<span class="keyword">...</span>
0297         Sup.intScaleFact_dbpcnt(n),<span class="keyword">...</span>
0298         Sup.absorption_dbpm(n)]= deal(C{:});
0299     
0300     <span class="comment">% Read Profile Data.</span>
0301     
0302     
0303     <span class="comment">% Logic to account for WR2 bug that puts $ in for intensity or</span>
0304     <span class="comment">% backscatter.</span>
0305     <span class="keyword">if</span> ignoreBS==0
0306         C = textscan(fid,<span class="string">'%f %f %f %f %f %f %f %f %f %f %f %f %f'</span>,Sup.bins(n));
0307         [<span class="keyword">...</span>
0308             Wat.binDepth(1:Sup.bins(n),n),<span class="keyword">...</span>
0309             Wat.vMag(1:Sup.bins(n),n),<span class="keyword">...</span>
0310             Wat.vDir(1:Sup.bins(n),n),<span class="keyword">...</span>
0311             Wat.vEast(1:Sup.bins(n),n),<span class="keyword">...</span>
0312             Wat.vNorth(1:Sup.bins(n),n),<span class="keyword">...</span>
0313             Wat.vVert(1:Sup.bins(n),n),<span class="keyword">...</span>
0314             Wat.vError(1:Sup.bins(n),n),<span class="keyword">...</span>
0315             Wat.backscatter(1:Sup.bins(n),n,1),<span class="keyword">...</span>
0316             Wat.backscatter(1:Sup.bins(n),n,2),<span class="keyword">...</span>
0317             Wat.backscatter(1:Sup.bins(n),n,3),<span class="keyword">...</span>
0318             Wat.backscatter(1:Sup.bins(n),n,4),<span class="keyword">...</span>
0319             Wat.percentGood(1:Sup.bins(n),n),<span class="keyword">...</span>
0320             Q.unit(1:Sup.bins(n),n)] = deal(C{:});
0321     <span class="keyword">else</span>
0322         C = textscan(fid,<span class="string">'%f %f %f %f %f %f %f %s %s %s %s %f %f'</span>,Sup.bins(n));
0323         [<span class="keyword">...</span>
0324             Wat.binDepth(1:Sup.bins(n),n),<span class="keyword">...</span>
0325             Wat.vMag(1:Sup.bins(n),n),<span class="keyword">...</span>
0326             Wat.vDir(1:Sup.bins(n),n),<span class="keyword">...</span>
0327             Wat.vEast(1:Sup.bins(n),n),<span class="keyword">...</span>
0328             Wat.vNorth(1:Sup.bins(n),n),<span class="keyword">...</span>
0329             Wat.vVert(1:Sup.bins(n),n),<span class="keyword">...</span>
0330             Wat.vError(1:Sup.bins(n),n),<span class="keyword">...</span>
0331             dummy,<span class="keyword">...</span>
0332             dummy,<span class="keyword">...</span>
0333             dummy,<span class="keyword">...</span>
0334             dummy,<span class="keyword">...</span>
0335             Wat.percentGood(1:Sup.bins(n),n),<span class="keyword">...</span>
0336             Q.unit(1:Sup.bins(n),n)] = deal(C{:});
0337     <span class="keyword">end</span>
0338     
0339 <span class="keyword">end</span> <span class="comment">% for loop through ensembles</span>
0340 
0341 <span class="comment">% Close File</span>
0342 fclose(fid);
0343 <span class="comment">% disp('Data Input Complete');</span>
0344 
0345 <span class="comment">%% Screen Data</span>
0346 <span class="comment">% Screens invalid data replacing them with nan</span>
0347 
0348 <span class="comment">% Apply data screening if requested.</span>
0349 <span class="keyword">if</span> screenData==1
0350     
0351     Wat.vNorth(Wat.vNorth==-32768)=nan;
0352     Wat.vEast(Wat.vEast==-32768)=nan;
0353     Wat.vError(Wat.vError==-32768)=nan;
0354     Wat.vVert(Wat.vVert==-32768)=nan;
0355     Wat.vMag(Wat.vMag==-32768)=nan;
0356     Wat.vDir(Wat.vDir==-32768)=nan;
0357     Wat.percentGood(Wat.percentGood==-32768)=nan;
0358     Wat.backscatter(Wat.backscatter==-32768)=nan;
0359     
0360     
0361     Nav.bvNorth(Nav.bvNorth==-32768)=nan;
0362     Nav.bvEast(Nav.bvEast==-32768)=nan;
0363     Nav.bvError(Wat.vError==-32768)=nan;
0364     Nav.bvVert(Nav.bvVert==-32768)=nan;
0365     Nav.depth(Nav.depth==0)=nan;
0366     Nav.lat_deg(Nav.lat_deg==30000)=nan;
0367     Nav.long_deg(Nav.long_deg==30000)=nan;
0368     Nav.gpsVnorth(Nav.gpsVnorth==-32768)=nan;
0369     Nav.gpsVeast(Nav.gpsVeast==-32768)=nan;
0370     Q.unit(Q.unit==2147483647)=nan;
0371 <span class="keyword">end</span>;
0372 
0373 <span class="comment">% Assign Data to One Structure</span>
0374 A.Sup=Sup;
0375 A.Wat=Wat;
0376 A.Nav=Nav;
0377 A.Sensor=Sensor;
0378 A.Q=Q;
0379 
0380 <span class="comment">% Close waitbar</span>
0381 close(hwait);</pre></div>
<hr><address>Generated on Tue 30-Apr-2013 10:18:12 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
</body>
</html>